﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System;


//-------------------------------PUZ-------------------------------//


public class MainMenu : MonoBehaviour
{
    //一级面板
    public RectTransform mainPanel;//主面板
    //二级面板
    public RectTransform childPanel;//儿童模式面板
    public RectTransform parentPanel;//亲子模式面板
    //三级面板
    public RectTransform leftBraPanel;//左脑面板
    public RectTransform rightBraPanel;//右脑面板

    //一级面板按钮
    public Button btnChild;//儿童模式按钮
    public Button btnParent;//亲子模式按钮

    //二级面板按钮
    public Button btnLeftBra;//左脑按钮
    public Button btnRightBra;//右脑按钮

    //三级面板按钮
    public Button btnMath;//算数按钮
    public Button btnLan;//文学按钮
    public Button btnEng;//外语按钮
    public Button btnDraw;//画画按钮
    public Button btnMus;//音乐按钮
    public Button btnDre;//换装按钮

    public Button btnChildPanelBack;//儿童模式后退按钮
    public Button btnLeftBrainPanelBack;//左脑后退按钮
    public Button btnRightBrainPanelBack;//右脑后退按钮

    // Start is called before the first frame update
    void Start()
    {
        //--------------------------------------------主界面--------------------------------------------
        MainPanelMenu();//显示主面板
        void MainPanelMenu()//主面板显示
        {
            mainPanel.GetComponent<UITween>().SetTargetPos();//设置目标
            StartCoroutine(mainPanel.GetComponent<UITween>().MoveTo());//开始移动
        }
        void MainPanelMenuBack()//主面板隐藏
        {
            mainPanel.GetComponent<UITween>().SetStartPos();//返回初始位置
            StartCoroutine(mainPanel.GetComponent<UITween>().MoveTo());//开始移动
        }

        //--------------------------------------------亲子模式--------------------------------------------
        //监听（亲子模式）事件
        btnParent.onClick.AddListener(delegate
        {
            mainPanel.GetComponent<UITween>().SetButtonHandle(ParentPanelMenu);
            MainPanelMenuBack();//隐藏主面板
        });
        void ParentPanelMenu()//儿童模式面板显示
        {
            //SceneManager.LoadScene("ThreeTest");
            MainPanelMenu();
        }       

        //--------------------------------------------儿童模式--------------------------------------------
        //监听（儿童模式）事件
        btnChild.onClick.AddListener(delegate
        {
            mainPanel.GetComponent<UITween>().SetButtonHandle(ChildPanelMenu);
            MainPanelMenuBack();//隐藏主面板
        });
        void ChildPanelMenu()//儿童模式面板显示
        {
            childPanel.GetComponent<UITween>().SetTargetPos();
            StartCoroutine(childPanel.GetComponent<UITween>().MoveTo());
        }
        void ChildPanelMenuBack()//儿童模式面板隐藏
        {
            childPanel.GetComponent<UITween>().SetStartPos();
            StartCoroutine(childPanel.GetComponent<UITween>().MoveTo());
        }
        btnChildPanelBack.onClick.AddListener(delegate 
        {
            childPanel.GetComponent<UITween>().SetButtonHandle(MainPanelMenu);
            ChildPanelMenuBack();
        });

        //--------------------------------------------左脑--------------------------------------------
        //监听（左脑）事件
        btnLeftBra.onClick.AddListener(delegate
        {
            childPanel.GetComponent<UITween>().SetButtonHandle(LeftBraPanelMenu);
            ChildPanelMenuBack();//隐藏儿童模式面板
        });
        void LeftBraPanelMenu()//左脑面板显示
        {
            leftBraPanel.GetComponent<UITween>().SetTargetPos();
            StartCoroutine(leftBraPanel.GetComponent<UITween>().MoveTo());
        }
        void LeftBraPanelMenuBack()//左脑面板隐藏
        {
            leftBraPanel.GetComponent<UITween>().SetStartPos();
            StartCoroutine(leftBraPanel.GetComponent<UITween>().MoveTo());
        }
        btnLeftBrainPanelBack.onClick.AddListener(delegate
        {
            leftBraPanel.GetComponent<UITween>().SetButtonHandle(ChildPanelMenu);
            LeftBraPanelMenuBack();
        });

        //--------------------------------------------算数/文学/外语--------------------------------------------
        //监听（算数）事件
        btnMath.onClick.AddListener(delegate
        {
            leftBraPanel.GetComponent<UITween>().SetButtonHandle(MathPanelMenu);
            LeftBraPanelMenuBack();//隐藏主面板
        });
        void MathPanelMenu()//跳转算数界面
        {
            SceneManager.LoadScene("ThreeTest");
        }
        //监听（文学）事件
        btnLan.onClick.AddListener(delegate
        {
            leftBraPanel.GetComponent<UITween>().SetButtonHandle(LanPanelMenu);
            LeftBraPanelMenuBack();//隐藏主面板
        });
        void LanPanelMenu()//跳转文学界面
        {
            SceneManager.LoadScene("ThreeTest");
        }
        //监听（外语）事件
        btnEng.onClick.AddListener(delegate
        {
            leftBraPanel.GetComponent<UITween>().SetButtonHandle(EngPanelMenu);
            LeftBraPanelMenuBack();//隐藏主面板
        });
        void EngPanelMenu()//跳转外语界面
        {
            SceneManager.LoadScene("ThreeTest");
        }

        //--------------------------------------------右脑--------------------------------------------
        //监听（右脑）事件
        btnRightBra.onClick.AddListener(delegate
        {
            childPanel.GetComponent<UITween>().SetButtonHandle(RightBraPanelMenu);
            ChildPanelMenuBack();//隐藏儿童模式面板
        });
        void RightBraPanelMenu()//右脑面板显示
        {
            rightBraPanel.GetComponent<UITween>().SetTargetPos();
            StartCoroutine(rightBraPanel.GetComponent<UITween>().MoveTo());
        }
        void RightBraPanelMenuBack()//右脑面板隐藏
        {
            rightBraPanel.GetComponent<UITween>().SetStartPos();
            StartCoroutine(rightBraPanel.GetComponent<UITween>().MoveTo());
        }
        btnRightBrainPanelBack.onClick.AddListener(delegate
        {
            rightBraPanel.GetComponent<UITween>().SetButtonHandle(ChildPanelMenu);
            RightBraPanelMenuBack();
        });

        //--------------------------------------------画画/音乐/换装--------------------------------------------
        //监听（画画）事件
        btnDraw.onClick.AddListener(delegate
        {
            leftBraPanel.GetComponent<UITween>().SetButtonHandle(DrawPanelMenu);
            LeftBraPanelMenuBack();//隐藏主面板
        });
        void DrawPanelMenu()//跳转画画界面
        {
            SceneManager.LoadScene("Draw");
        }
        //监听（音乐）事件
        btnMus.onClick.AddListener(delegate
        {
            leftBraPanel.GetComponent<UITween>().SetButtonHandle(MusPanelMenu);
            LeftBraPanelMenuBack();//隐藏主面板
        });
        void MusPanelMenu()//跳转音乐界面
        {
            SceneManager.LoadScene("AudioPlayer");
        }
        //监听（换装）事件
        btnDre.onClick.AddListener(delegate
        {
            leftBraPanel.GetComponent<UITween>().SetButtonHandle(DrePanelMenu);
            LeftBraPanelMenuBack();//隐藏主面板
        });
        void DrePanelMenu()//跳转换装界面
        {
            SceneManager.LoadScene("ClothesOne");
        }
    }
    private void Update()
    {
        
    }
}
